//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System.ComponentModel;
using System.Drawing.Design;
using Microsoft.Practices.EnterpriseLibrary.Configuration.Design;

namespace EntLibContrib.Query.Configuration.Design
{
	/// <summary>
	/// Represents a query using a data file.
	/// </summary>
	public abstract class FileQueryNode : QueryNode
	{
		#region Fields
		private string dataFile;
		#endregion

		#region Properties
		/// <summary>
		/// Gets the name of the custom file command to use for this query.
		/// </summary>
		/// <value>The name of the custom file command to use for this query.</value>
		[Editor(typeof(ReferenceEditor), typeof(UITypeEditor))]
		[ReferenceType(typeof(FileCommandNode))]
		[QueryCategory("CategoryCustom")]
		[QueryDescription("FileQueryCommandNameDescription")]
		public FileCommandNode FileCommandName
		{
			get { return (FileCommandNode)CustomCommand; }
			set
			{
				CustomCommand = LinkNodeHelper.CreateReference<FileCommandNode>(FileCommandName,
																																				value,
																																				OnCustomCommandNodeRemoved,
																																				OnCustomCommandNodeRenamed);
				CustomCommandName = (null == CustomCommand) ? string.Empty : CustomCommand.Name;
			}
		}

		/// <summary>
		/// Gets or sets the data file.
		/// </summary>
		/// <value>The data file for this node.</value>
		[QueryCategory("CategoryProvider")]
		[QueryDescription("FileQueryDataFileDescription")]
		public virtual string DataFile
		{
			get { return dataFile; }
			set
			{
				if (value != null)
					dataFile = value;
			}
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="FileQueryNode"/> class.
		/// </summary>
		protected FileQueryNode ()
		{
		}
		#endregion
	}
}